package com.als.healthymananger.controller;


import com.als.healthymananger.entity.User;
import com.als.healthymananger.utils.RespBean;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@Tag(name = "系统管理-用户管理")
public interface UsersApi {
    /**
     * 添加用户
     */
    @PostMapping("/")
    @Operation(summary = "添加用户", description = "添加用户", security = @SecurityRequirement(name = "bearer-key"))
    @Parameter(name = "suggestion", description = "健康方案信息", in = ParameterIn.QUERY, schema = @Schema(ref = "user"), required = true)
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "添加成功"),
            @ApiResponse(responseCode = "400", description = "添加失败"),
            @ApiResponse(responseCode = "401", description = "用户未登录"),
            @ApiResponse(responseCode = "403", description = "权限不足"),
            @ApiResponse(responseCode = "412", description = "先决条件不足，如数据格式不对")
    })
    public RespBean createUsers(@RequestBody @Validated User user);

    /**
     * 删除用户
     */
    @DeleteMapping("/{username}")
    @Operation(summary = "删除用户", description = "将用户enable项设置为否", security = @SecurityRequirement(name = "bearer-key"))
    @Parameter(name = "userId", description = "用户序列", in = ParameterIn.PATH, required = true)
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "删除成功"),
            @ApiResponse(responseCode = "400", description = "删除失败"),
            @ApiResponse(responseCode = "401", description = "用户未登录"),
            @ApiResponse(responseCode = "403", description = "权限不足"),
            @ApiResponse(responseCode = "412", description = "先决条件不足，如数据格式不对")
    })
    public RespBean deleteUsers(@PathVariable("username")String username);

    /**
     * 修改用户
     */
    @PutMapping("/{username}")
    @Operation(summary = "修改用户", description = "修改用户", security = @SecurityRequirement(name = "bearer-key"))
    @Parameters({
            @Parameter(name = "username", description = "用户名", in = ParameterIn.PATH, required = true),
    })
    @Parameter(name = "suggestion", description = "健康方案信息", in = ParameterIn.QUERY, schema = @Schema(ref = "user"), required = true)
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "修改成功"),
            @ApiResponse(responseCode = "400", description = "修改失败"),
            @ApiResponse(responseCode = "401", description = "用户未登录"),
            @ApiResponse(responseCode = "403", description = "权限不足"),
            @ApiResponse(responseCode = "412", description = "先决条件不足，如数据格式不对")
    })
    public RespBean updateUsers(@PathVariable("username")int username,
                                @RequestBody @Validated User user);

    /**
     * 获取用户信息
     */
    @GetMapping("/{username}")
    @Operation(summary = "获取用户信息", description = "获取用户信息", security = @SecurityRequirement(name = "bearer-key"))
    @Parameter(name = "username", description = "用户名", hidden = true)
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "获取成功"),
            @ApiResponse(responseCode = "400", description = "获取失败"),
            @ApiResponse(responseCode = "401", description = "用户未登录"),
            @ApiResponse(responseCode = "403", description = "权限不足"),
            @ApiResponse(responseCode = "412", description = "先决条件不足，如数据格式不对")
    })
    public RespBean getUsers(@RequestAttribute("username")String username);
}
